<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>平台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
    <style>
        thead tr th{text-align: center!important;}
        tr td{text-align: center!important;}
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <form action="/cash/cashDetail" id="seachFrom" class="layui-form">
                    <div class="layui-card-body">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th>ID</th>
                                <th>申请商家</th>
                                <th>申请商品</th>
                                <th>红包总金额</th>
                                <th>单个红包金额</th>
                                <th>类型</th>
                                <th>状态</th>
                                <th>申请时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <c:forEach items="${pageInfo.records}" var="l">
                                <tr>
                                    <td width="5%">${l.id}</td>
                                    <td width="16%">${l.businessName}</td>
                                    <td width="10%">${l.proCode}</td>
                                    <td width="8%">${l.totalMoney}</td>
                                    <td width="10%">${l.perMoney}</td>
                                    <td width="7%">${l.typeName}</td>
                                    <td width="7%">
                                        <c:if test="${l.status==0}"><span class="layui-badge">待审核</span></c:if>
                                        <c:if test="${l.status==1}"><span class="layui-badge layui-bg-green">审核通过</span></c:if>
                                    </td>
                                    <td width="12%"><fmt:formatDate value="${l.updateTime}" pattern="yyyy-MM-dd HH:mm"></fmt:formatDate></td>
                                    <td width="8%">
                                        <c:if test="${l.status == 0}">
                                            <button data-id="${l.id}" data-status="1" data-code="${l.proCode}" data-type="updateThis" type="button"
                                                    class="layui-btn layui-btn-sm layui-btn-normal updateThis">通过</button><br>
                                            <button data-id="${l.id}" data-status="0" data-code="${l.proCode}" data-type="updateThis" type="button"
                                                    class="layui-btn layui-btn-sm layui-btn-warm updateThis" style="margin-top: 5px">驳回</button><br>
                                        </c:if>
                                    </td>
                                </tr>
                            </c:forEach>
                            </tbody>
                        </table>
                        <div class="test-table-reload-btn" style="margin-top: 10px;">
                            <%@include file="../paging.jsp" %>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'laydate','form'], function(){
        var laydate = layui.laydate,form=layui.form;
        form.render()
        var today = new Date();
        var last = today.getFullYear() + "-" + today.getMonth() + "-" +today.getDate();
        today = today.getFullYear() + "-" + (today.getMonth()+1) + "-" +today.getDate();
        laydate.render({
            elem: '#laydate-cn',
            range:'~',
            max:today
        });

        var active = {
            updateThis:function (id,status,proCode,url) {
                layer.confirm('确定操作吗？', function(){
                    $.ajax({
                        url: url,
                        data: {"id": id, 'status': status,'proCode':proCode},
                        dataType: "json",
                        type: "post",
                        success: function (data) {
                            if (data.status) {
                                layer.msg(data.desc,{icon:1});
                                setTimeout(function () {
                                    window.location.reload();
                                }, 1000)
                            } else {
                                layer.msg(data.desc,{icon:2});
                            }
                        }
                    });
                });
            }
        };

        $('.updateThis').on('click',function () {
            var updateType = $(this).data('type');
            var id = $(this).data('id');
            var status = $(this).data('status');
            var proCode = $(this).data('code');
            var url = "/activity/handleRedPacketApply";
            active[updateType] && active[updateType].call(this,id,status,proCode,url);
        })
    });
</script>
</body>
</html>